package com.example.module_home.testwidget

import android.graphics.Color
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import com.example.lib_widget.redpacket.RedPacketEnum
import com.example.lib_widget.redpacket.RedPacketEvent
import com.example.lib_widget.redpacket.RedPacketView
import com.example.lib_widget.redpacket.RedPacketWidget
import com.example.lib_widget.titlebar.VerticalTextView
import com.example.lib_widget.titlebar.XiGuaTitleBar
import com.example.module_home.R
import org.greenrobot.eventbus.EventBus

class WidgetActivity : AppCompatActivity() {
//    private lateinit var tv: VerticalTextView
    private lateinit var bar:XiGuaTitleBar
//    private lateinit var redView:RedPacketView
    private lateinit var redPacketView: RedPacketWidget
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_widget)
//        tv = findViewById(R.id.tv)
//        tv.setAnimTime(1000)
//        tv.setTextList(arrayListOf("叶珂","黄晓明"))
//        tv.setTextStillTime(2000)
//        tv.setText(30f,20, Color.RED)
//        tv.setOnItemClickListener {
//            Toast.makeText(this,"点击了 $it",Toast.LENGTH_SHORT).show()
//        }
//        tv.startAutoScroll()
        bar = findViewById(R.id.bar)
        bar.setTextList(arrayListOf("叶珂","黄晓明"))
        bar.setTitleBarClickCallback{
            Toast.makeText(this@WidgetActivity,"点击了 $it",Toast.LENGTH_SHORT).show()
        }

//        redView = findViewById(R.id.red_view)
//        redView.setCallback(object :RedPacketView.Callback{
//            override fun start() {
//                Log.d("TAG", "start: ")
//            }
//
//            override fun pause(angle: Int) {
//                Log.d("TAG", "pause: $angle")
//            }
//
//            override fun resume() {
//                Log.d("TAG", "resume:")
//            }
//
//            override fun completed() {
//                Log.d("TAG", "completed:上报金币")
//            }
//
//        })

        redPacketView = findViewById(R.id.red_packet_view);
        redPacketView.setTvNum(1000)
        redPacketView.setStateCallback {
            Toast.makeText(this@WidgetActivity,"网络请求上报金币",Toast.LENGTH_SHORT)
        }


    }

    fun stop(view: View) {
//        redView.stop()
    }
    fun resume(view: View) {
//        redView.resume()
        EventBus.getDefault().post(RedPacketEvent(RedPacketEnum.RESUME))
    }
    fun pasue(view: View) {
//        redView.pause()
        EventBus.getDefault().post(RedPacketEvent(RedPacketEnum.PAUSE))
    }

    fun start(view: View) {
//        redView.startAnimator()
        EventBus.getDefault().post(RedPacketEvent(RedPacketEnum.INIT))
    }
}